import pymysql
db_config = {
      "host":"119.29.78.234",
       "port":3306,
       "user":"root",
       "password":"dhcc@2020",
       "db":"test123"
}
db = pymysql.connect(**db_config)
cursor = db.cursor()
sql = "SELECT * FROM userinfo"
cursor.execute(sql)
res = cursor.fetchmany(3)   # 第一次查询表中的前3行数据
print(res)
res = cursor.fetchmany(3)    # 第二次查询下一个3行的数据
print(res)
cursor.close()
db.close()